<?#//v.3.0.0

#///////////////////////////////////////////////////////
#//  COPYRIGHT 2004 Phpauction.org ALL RIGHTS RESERVED//
#///////////////////////////////////////////////////////

require('../includes/config.inc.php');
include "loggedin.inc.php";
include $include_path.'platforms.inc.php';

$ABSOLUTEWIDTH = 550;

#// Retrieve data
$query = "SELECT year FROM PHPAUCTIONXL_currentplatforms WHERE (year<>".date("Y")."
			  OR (year=".date("Y")." AND month<>".date("m").")) GROUP BY year ORDER BY year desc";
$res = @mysql_query($query);
if(!$res)
{
	print "Error: $query".mysql_error();
	exit;
}
while($year = mysql_fetch_array($res))
{
	$query = "SELECT * FROM PHPAUCTIONXL_currentplatforms WHERE year=".$year[year]." AND month<>'".date("m")."' GROUP BY month ORDER BY month desc";
	$r_ = @mysql_query($query);
	if(!$r_)
	{
		print "Error: $query".mysql_error();
		exit;
	}
	//print $year[year]."<BR>";
	while($month = mysql_fetch_array($r_))
	{
		$YEARS[$year[year]][$month[month]] = $month[month];
	}
}
?>
<HTML>
<HEAD>
<link rel='stylesheet' type='text/css' href='style.css' />
<link href="css/main.css" rel="stylesheet" type="text/css">
</HEAD>
<body  leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0" class="titulo">
        <tr> 
          <td class="icono"><img src="images/stats_icon2.gif" width="34" height="26" ></td>
          <td class="breadcrumbs"><p><span><?=$MSG_25_0023?></span>&nbsp;&gt;&gt;&nbsp;<?=$MSG_5318?></p></td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td align="center" valign="middle">&nbsp;</td>
  </tr>
    <tr> 
    <td align="center" valign="middle">
  <TABLE WIDTH=95% CELLPADDING=0 CELLSPACING=0 BORDER=0 ALIGN="CENTER" class="base" style="border:1px solid #ccc;">
    <TR BGCOLOR="#FFCC00">
      <TD ALIGN=CENTER colspan="2" bgcolor="#eeeeee">
        <p class=title>
          <?=$MSG_5438."<I>$SETTINGS[sitename]</I>"?>
          <BR>
          <?=$MSG_5281;?>
          </p>
        <p>
			<A HREF=viewaccessstats.php?><?=$MSG_5143?></A> |
			<A HREF=viewbrowserstats.php?><?=$MSG_5165?></A> |
			<A HREF=viewdomainstats.php?><?=$MSG_5166?></A>
			</p>
      </TD>
    </TR>
    <TR BGCOLOR=#FFFFFF>
      <TD width="146">&nbsp;</TD>
      <TD width="626">&nbsp;</TD>
    </TR>
    <tr>
      <td width="146" height="21" class="title"> 
        <p>
        <?=$MSG_5280?>
        </p> </td>
      <td class="title" height="21" width="626" align="right"> 
		<a href="viewplatformstats.php">
        <?=$MSG_5282?>
        </a>  </td>
      <?
      if(is_array($YEARS))
      {
      	while(list($k,$v) = each($YEARS))
      	{
		?>
		<TR>
				<TD COLSPAN=2  class="error">
					<B><?=$k?></B>
				</TD>
		</TR>
			<?
			while(list($t,$z) = each($v))
			{
			?>
    		<TR BGCOLOR=#eeeeee>

      <TD>
	  	<b>
        <?=$t?>
        </b> </TD>

      <TD width="626">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="600"> 
              <?
              $query = "SELECT platform,counter
				   			 FROM PHPAUCTIONXL_currentplatforms
				   		 	 WHERE year='$k' AND month='$t'";
              $RR = @mysql_query($query);
              if(!$RR)
              {
              	print "Error: $query<BR>".mysql_error();
              	exit;
              }
              else
              {
              	while($row = mysql_fetch_array($RR))
              	{
              		$query = "SELECT max(counter) as MAX, sum(counter) as TOTAL
				   					  FROM PHPAUCTIONXL_currentplatforms
				   		 			  WHERE year='$k' AND month='$t'";
              		$R___ = @mysql_query($query);
              		$MAX = mysql_result($R___,0,"MAX");
              		$TOTAL = mysql_result($R___,0,"TOTAL");
              		
              		$WIDTH = ( $row[counter] * $ABSOLUTEWIDTH ) / $MAX;
              		$PERCENAGE = ceil(intval($row[counter] * 100 / $TOTAL));
              		
					   ?>
            				
							
							<B><?=$row[platform]?></B>
            				<table width="100%" border="0" cellspacing="0" cellpadding="0">
                			  <tr>
                				<td width="2%">
                    			  <table border=0 callpadding=0 cellspacing=0 width=<?=intval($WIDTH)?> bgcolor=#66CC00>
                    				<tr>
                        			  <td>&nbsp; </td>
                    				</tr>
                    			  </table>
                				</td>
                				<td width="98%">
                    			  &nbsp;<?=$PERCENAGE?>
                    			  % </td>
                			  </tr>
            				</table>
			<?
              	}
              }
			?>
            </td>
          </tr>
        </table>
    		  </TD>
    		</TR>
    		<?
			}
      	}
      }
		?>
  </TABLE><br>
  </TD>
  </TR>
  </TABLE>
  </BODY>
  </HTML>